Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for duplicate output filenames. #6308

Merged
merged 3 commits into from
Nov 14, 2018
Merged

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Nov 12, 2018

This generates an error warning if it detects that different units would output the same file name. This can happen in a few situations:

This includes a few cleanups/consolidations:

  • export_path added to OutputFile so there is one place where the --out-dir filename logic is located.
  • TargetKind::description() added for a simple way to get a human-readable name of a target kind.
  • The PartialOrd changes are a slight performance improvement (overall things are now slightly faster even though it is doing more work).

Closes #5524, closes #6293.

@rust-highfive
Copy link

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@ehuss
Copy link
Contributor Author

ehuss commented Nov 12, 2018

@alexcrichton I didn't fully follow your last comment, because it kinda sounded like you were saying two different things. I think generating an error if the current command would generate duplicates is the right thing to do, because almost certainly that is the wrong behavior. These can be converted to warnings if needed, though.

I might follow up with a separate PR sometime later to clean up the OutputFile calculation. It currently does not generate all outputs correctly. In particular, some debug files are missing because file_types is making hardlinking decisions which should be deferred. Also, doc and doctests both create wrong paths (and handling doc units correctly could simplify some special cases).

Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great to me! I think my last comment was "let's do what this PR does" and then possibly emit warnings instead of errors for the time being. I think I'd personally still be slightly in favor of doing that, emitting a warning.

Do you think it's feasible to tweak the output here to say that it will soon become a hard error (perhaps with an issue URL as well) and leave it as a warning for now?

@@ -72,18 +72,6 @@ impl<'a> Unit<'a> {
}
}

impl<'a> Ord for Unit<'a> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, was this done for performance reasons or for correctness reasons?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is only for performance. The old code was rehashing every field for every comparison.

@ehuss
Copy link
Contributor Author

ehuss commented Nov 13, 2018

Do you think it's feasible to tweak the output here to say that it will soon become a hard error (perhaps with an issue URL as well) and leave it as a warning for now?

Yea, sounds good! Updated with a corresponding tracking issue.

@alexcrichton
Copy link
Member

@bors: r+

💯

@bors
Copy link
Contributor

bors commented Nov 13, 2018

📌 Commit a10eb01 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Nov 13, 2018

⌛ Testing commit a10eb01 with merge dc5add8ee9f6527e222be2d95b9c5672c3cca04f...

@bors
Copy link
Contributor

bors commented Nov 14, 2018

💔 Test failed - status-appveyor

@ehuss
Copy link
Contributor Author

ehuss commented Nov 14, 2018

🤔 forgot to check windows after switching to a warning. Looks like it's a little more sensitive to concurrent writers to the same library. I think the other tests should be safe.

@alexcrichton
Copy link
Member

Looks like one of our old friends may be sneaking back...

@bors: r+

@bors
Copy link
Contributor

bors commented Nov 14, 2018

📌 Commit 69c6363 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Nov 14, 2018

⌛ Testing commit 69c6363 with merge e07088b...

bors added a commit that referenced this pull request Nov 14, 2018
Check for duplicate output filenames.

This generates an error if it detects that different units would output the same file name. This can happen in a few situations:
- Multiple targets in a workspace use the same name.
- `--out-dir` in some cases (like `examples` because it does not include the directory).
- Bugs in cargo (like #5524, #5444)

This includes a few cleanups/consolidations:
- `export_path` added to `OutputFile` so there is one place where the `--out-dir` filename logic is located.
- `TargetKind::description()` added for a simple way to get a human-readable name of a target kind.
- The `PartialOrd` changes are a slight performance improvement (overall things are now slightly faster even though it is doing more work).

Closes #5524, closes #6293.
@bors
Copy link
Contributor

bors commented Nov 14, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing e07088b to master...

@bors bors merged commit 69c6363 into rust-lang:master Nov 14, 2018
@ehuss ehuss added this to the 1.32.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

What to do about duplicate targets in a workspace? Warn on duplicate artifact creation
4 participants